package com.gyl.Container;

import org.apache.commons.lang.StringUtils;


public class ServiceProvider {
	
	private static ServiceProviderCord spc ;
	
	static {
		spc = new ServiceProviderCord() ;
		spc.load("spring/applicationContext.xml") ;
	}
	
	public static Object getService(String serviceName) {
		if(StringUtils.isBlank(serviceName) || "".equals(serviceName)) {
			throw new RuntimeException("当前服务名称不存在") ;
		}
		Object object = null ;
		if(spc.context.containsBean(serviceName)) {
			object = spc.context.getBean(serviceName) ;
		}
		if(object == null) {
			throw new RuntimeException("当前服务名称【" + serviceName +"】下的节点不存在") ;
		}
		return object ;
	}

}
